package com.joysuch.wwyt.mh.controller;

import com.joysuch.wwyt.core.common.ajax.ResultBean;
import com.joysuch.wwyt.core.support.Context;
import com.joysuch.wwyt.mh.bean.MhMonitoringRealTimeListBean;
import com.joysuch.wwyt.mh.service.MhMonitoringRealTimeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.querydsl.QPageRequest;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/mh/monitoring-real-time")
public class MhMonitoringRealTimeController {

    @Autowired
    private MhMonitoringRealTimeService mhMonitoringRealTimeService;

    //实时监测列表
    @GetMapping("/list")
    public ResultBean list(Integer page, Integer size, String name, String pointCode, Long monitoringTypeId) {
        Page<MhMonitoringRealTimeListBean> list = mhMonitoringRealTimeService.list(QPageRequest.of(page, size), name, pointCode, monitoringTypeId, Context.getCurrentTenantId(), Context.getCompanyCode());
        return ResultBean.pageData(list.getContent(), list.getTotalElements());
    }

    //实时监测列表-不带数据权限
    @GetMapping("/list-with-out-permission")
    public ResultBean listWithOutPermission(Integer page, Integer size, String name, String pointCode, Long monitoringTypeId) {
        Page<MhMonitoringRealTimeListBean> list = mhMonitoringRealTimeService.list(QPageRequest.of(page, size), name, pointCode, monitoringTypeId,Context.getCurrentTenantId(), Context.getCompanyCode());
        return ResultBean.pageData(list.getContent(), list.getTotalElements());
    }

}
